<cfsetting enablecfoutputonly="true">
<cfswitch expression="#thisTag.executionMode#">
	<cfcase value="start">
		<cfparam name="attributes.class" default="formValidation">
		<cfparam name="attributes.id" default="" type="string">
		<cfparam name="attributes.value" default="">
		<cfparam name="attributes.formatter" type="string" default="">
		<cfparam name="attributes.formatterMask" type="string" default="">
		<cfparam name="attributes.formatterType" type="string" default="">
		<cfparam name="attributes.formatterVersion" type="string" default="">
		<cfif StructKeyExists(caller,'root')>
			<cfset root = caller.root>
		<cfelse>
			<cfset root = caller>
		</cfif>
		<cfif NOT structKeyExists(root,"coop")>
			<cfthrow detail="Missing required COOP object on calling page.">
		</cfif>
		<cfif attributes.id EQ ''>
			<cfthrow detail="ID attribute required" message="Missing required attribute: 'id'" errorcode="coop.tag.attributes">
		</cfif>
		<cfif NOT thisTag.hasEndTag>
			<cfthrow detail="End tag required" message="All coop tags require an end tag." errorcode="coop.tag">
		</cfif>
		<cfif NOT listFindNoCase(getBaseTagList(),"CF_FORM")>
			<cfthrow detail="Base Form tag required" message="The base COOP:form tag is required for the valdiation text to work." errorcode="coop.tag">
		</cfif>
		<cfscript>
		standardAttributes = 'class,formatter,formatterVersion,formatterMask,formatterType,value,id';
		attributes = root.coop.mergeAttributes(attributes,root);
		attributeList = root.coop.createAttributeList(attributes,standardAttributes,root);
		if(NOT structKeyExists(getBaseTagData('cf_form'),"__validation")){
			getBaseTagData('cf_form').__validation = structNew();
		}
		if(NOT structKeyExists(getBaseTagData('cf_form').__validation,"#attributes.id#")){
			getBaseTagData('cf_form').__validation[attributes.id] = structNew();
			getBaseTagData('cf_form').__validation[attributes.id].visible = false;
		}
		</cfscript>
	</cfcase>
	<cfcase value="end">
		<cfif attributes.value EQ ''>
			<cfset attributes.value = thisTag.generatedContent>
		</cfif>
		<cfif len(attributes.formatter)>
			<cfset attributes.value = root.coop._formatter(attributes.formatter,attributes.value,attributes)>
		</cfif>
		<cfsaveContent variable="formElement"><cfoutput><span id="#attributes.id# "class="#attributes.class#"#attributeList#>#attributes.value#</span></cfoutput></cfsaveContent>
				<cfif getBaseTagData('cf_form').__validation[attributes.id].visible>
				<cfoutput>#formElement#</cfoutput>
				</cfif>
			<cfset thisTag.generatedContent = ''>
	</cfcase>
</cfswitch>
<cfsetting enablecfoutputonly="false">